<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/

if ($_REQUEST["primaryUsername"])
{
    $sPrimaryUsername = $_REQUEST["primaryUsername"];
}
else
{
    $sPrimaryUsername = $aInfo["primaryUsername"];
}

if ($_REQUEST["secondaryUsername"])
{
    $sSecondaryUsername = $_REQUEST["secondaryUsername"];
}
else
{
    $sSecondaryUsername = $aInfo["secondaryUsername"];
}

$aActiveEmployees = $Employee->GetActiveEmployees();

?>

<p><a href="<?=$_SERVER["PHP_SELF"];?>?page=listuserrels">List User Relationships</a></p>


<form method="post" action="<?=$_SERVER["PHP_SELF"];?>">
    <input type="hidden" name="nUserRelID" value="<?=$aInfo["ID"];?>">
    <input type="hidden" name="page" value="setuserrel">
<table border="0" cellpadding="0" cellspacing="0" class="app_table">
<tr class="app_row">
    <td>
	<b>Primary Username</b>
    </td>
    <td>
	<select name="primaryUsername" size="1" id="app_select">
	<?
	foreach($aActiveEmployees as $aEmployee)
	{
	    $sUsername = $aEmployee['username'];
	    $sFullname = $aEmployee['cn'];

	    if ($sUsername == $sPrimaryUsername)
	    {
		$s=" selected";
	    }
	    else
	    {
		$s="";
	    }
            ?>
            <option value="<?=$sUsername?>" <?=$s;?>><?=$sFullname?></option>
            <?
        }
	?>
	</select>
    </td>
</tr>
<tr class="app_row">
    <td>
	<b>Secondary Username</b>
    </td>
    <td>
	<select name="secondaryUsername" size="1" id="app_select">
	<?
	foreach($aActiveEmployees as $aEmployee)
	{
	    $sUsername = $aEmployee['username'];
	    $sFullname = $aEmployee['cn'];

	    if ($sUsername == $sSecondaryUsername)
	    {
		$s=" selected";
	    }
	    else
	    {
		$s="";
	    }
            ?>
            <option value="<?=$sUsername?>" <?=$s;?>><?=$sFullname?></option>
            <?
        }
	?>
	</select>
    </td>
</tr>
<tr class="app_row">
    <td>
	<b>Action</b>
    </td>
    <td>
	<?
	if($aInfo["actionID"] > 0)
	{
	    $sMultiSelect = "size='1'";
	}
	else
	{
	    $sMultiSelect = "multiple='yes' size='8'";
	}
	?>
	<select name="actionID[]" <?=$sMultiSelect?> id="app_select">
	<?
	$aAction=$RoleAdmin->GetRoleActions();
	
	for ($i=0; $i<count($aAction); $i++)
	{
	    if ($aInfo["actionID"]==$aAction[$i]["ID"])
	    {
		$s=" selected";
	    }
	    else
	    {
		$s="";
	    }
	    ?>
	    <option value="<?=$aAction[$i]["ID"];?>"<?=$s;?>><?=$aAction[$i]["name"];?> (<?=$aAction[$i]["type"];?>)</option>
	    <?
	}
	
	?>
	</select>
    </td>
</tr>
<tr class="app_row">
    <td>
	<b>Relationship Type</b>
    </td>
    <td>
	<input type="text" name="relationshipType" value="<?=$aInfo["relationshipType"];?>" size="30" id="app_textinput">
    </td>
</tr>
<tr class="app_row">
    <td colspan="2">
	<input type="submit" name="submit" value="Submit" id="app_submit">
    </td>
</tr>
</table>
</form>


